package cn.iocoder.yudao.module.crm.dal.mysql.customfieldData;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crm.dal.dataobject.customfieldData.CustomFieldDataDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.crm.controller.admin.customfieldData.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 自定义数据 Mapper
 *
 * @author 数创万维
 */
@Mapper
public interface CustomFieldDataMapper extends BaseMapperX<CustomFieldDataDO> {

    @Delete("DELETE FROM custom_field_data WHERE data_id = #{dataId}")
    void deleteByDataId(@Param("dataId") Long dataId);
    default PageResult<CustomFieldDataDO> selectPage(CustomFieldDataPageReqVO reqVO) {

        return selectPage(reqVO, new LambdaQueryWrapperX<CustomFieldDataDO>()
                .eqIfPresent(CustomFieldDataDO::getDataId, reqVO.getDataId())
                .eqIfPresent(CustomFieldDataDO::getFieldHeadId, reqVO.getFieldHeadId())
                .likeIfPresent(CustomFieldDataDO::getFieldName, reqVO.getFieldName())
                .betweenIfPresent(CustomFieldDataDO::getFieldDate, reqVO.getFieldDate())
                .betweenIfPresent(CustomFieldDataDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CustomFieldDataDO::getId));
    }

}